package com.example.carbonlife.controller;


import com.example.carbonlife.common.Result;
import com.example.carbonlife.entity.User;
import com.example.carbonlife.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;


    /**
     * 更新用户信息
     * @param user
     * @return
     */
    @PostMapping("/updateUser")
    public Result updateUserInfo(@RequestBody User user){
        return Result.success(userService.saveOrUpdate(user));
    }


    /**
     * 根据时间更新每周挑战
     * @param currentTime
     * @param id
     */
    @GetMapping("/updateDate")
    public Result updateDate(@RequestParam String currentTime, @RequestParam Integer id){
        return Result.success(userService.updateDate(currentTime, id));
    }

}
